package com.jhws.sys.appUpgrade.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jhws.core.db.BaseDao;
import com.jhws.sys.appUpgrade.bo.TblSoftDimBo;
import com.jhws.common.Page;
import com.jhws.sys.appUpgrade.dao.ITblSoftDimDAO;
import com.jhws.util.MailUtil;
import com.jhws.util.StringUtils;
import org.apache.commons.collections.MapUtils;

import javax.annotation.Resource;

public class TblSoftDimServiceSpringImpl implements ITblSoftDimService {
    private ITblSoftDimDAO tblSoftDimDAO;
    @Resource
    private BaseDao BaseDao;


    public ITblSoftDimDAO getTblSoftDimDAO() {
        return tblSoftDimDAO;
    }

    public void setTblSoftDimDAO(ITblSoftDimDAO tblSoftDimDAO) {
        this.tblSoftDimDAO = tblSoftDimDAO;
    }


    public Map findTblSoftDim(Map param) throws Exception {
        String hql = "from TblSoftDimBo where 1=1 ";
        String softLabel = MapUtils.getString(param, "softLabel");
        if (StringUtils.isNotEmpty(softLabel)) {
            hql += "and soft_label='" + softLabel + "' ";
        }
        String equType = MapUtils.getString(param, "equType");
        if (StringUtils.isNotEmpty(equType)) {
            hql += "and equ_type='" + equType + "' ";
        }
        hql += "ORDER BY cast(code_vision as integer)";
        return BaseDao.queryPage(hql);
    }


    public void save(TblSoftDimBo bo) throws Exception {
        BaseDao.saveOrUpdate(bo);
    }

    public List findTblSoftDimByWhere(String whereClause) throws Exception {
        return tblSoftDimDAO.findTblSoftDimByWhere(whereClause);
    }

    public TblSoftDimBo findTblSoftDimById(String TblSoftId) {
        return tblSoftDimDAO.getById(TblSoftId);
    }

    public void removeSoftDim(String TblSoftId) {
        tblSoftDimDAO.deleteTblSoftDim(TblSoftId);
    }

}
